/*
 * 10.1.cpp 1163_poj
 *
 *  Created on: 2012-5-16
 *      Author: jawinton
 */


#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 101

int triangle[MAX][MAX];
int result[MAX][MAX];
int n;

int main (void) {
	scanf("%d", &n);
	for (int i=0; i<n; i++) {
		for (int j=0; j<=i; j++) {
			scanf("%d", &triangle[i][j]);
			result[i][j] = -1;
		}
	}
	for (int i=0; i<n; i++)
		result[n-1][i] = triangle[n-1][i];
	for (int i=n-1; i>=1; i--) {
		for (int j=0; j<i; j++) {
			result[i-1][j] = max(triangle[i-1][j]+result[i][j], triangle[i-1][j]+result[i][j+1]);
		}
	}
	printf("%d\n", result[0][0]);
	return 0;
}
